from pathlib import Path

from text_renderer.config import NormPerspectiveTransformCfg, GeneratorCfg, RenderCfg
from text_renderer.corpus import CharCorpus, CharCorpusCfg

READER_ROOT = Path('D:/ocr/ocr_resources/reader/')

CONFIG_ROOT = Path('D:/workspace/python/train_data/train_data_configs/')

RENDER_ROOT = Path('D:/workspace/python/text_renderer/')

perspective_transform = NormPerspectiveTransformCfg(20, 20, 1.5)

text_paths = [READER_ROOT / "all_words/in_chars_words_clear.txt"]
chars_file = CONFIG_ROOT / "words/result_all.txt"
bg_dir = RENDER_ROOT / 'example_data/bg'
save_dir = READER_ROOT / 'train_data' / 'train_data_zy650w_7',

font_cfg = dict(
    font_dir=CONFIG_ROOT / 'fonts/chn',
    font_list_file=CONFIG_ROOT / "fonts/chn_windows.txt",
    font_size=(30, 31),
)


def base_cfg(
        name: str, corpus, corpus_effects=None, layout_effects=None, layout=None, gray=True
):
    return GeneratorCfg(
        # num_image=6500000,
        # num_image=500000,
        num_image=None,
        save_dir=save_dir,
        render_cfg=RenderCfg(
            bg_dir=bg_dir,
            perspective_transform=perspective_transform,
            gray=gray,
            layout_effects=layout_effects,
            layout=layout,
            corpus=corpus,
            corpus_effects=corpus_effects,
        ),
    )
